//
//  HNTurnAround.m
//  HeroNuts
//
//  Created by Magic on 5/18/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "HNTurnAround.h"
#import "HNActionCache.h"

@interface HNTurnAround()

-(void) toggleFaceDirection;

@end

@implementation HNTurnAround

#pragma mark HNTurnAround - initialization - preparing the action sequence to be run

-(id) initWithActorName:(NSString *)actor
{
	if ((self = [super init])) 
	{
        actions_ = [[NSMutableArray alloc] init];
        
        CCAnimate *turnLeft = [[HNActionCache sharedActionCache] actionByName:@"TURN_L" actor:actor];
        CCAnimate *turnRight = [[HNActionCache sharedActionCache] actionByName:@"TURN_R" actor:actor];
        CCCallFunc *toggleFace = [CCCallFunc actionWithTarget:self selector:@selector(toggleFaceDirection)];
    
        [actions_ addObject:turnLeft];
        [actions_ addObject:toggleFace];
        [actions_ addObject:turnRight];
	}
	
	return self;
}

-(void) toggleFaceDirection
{
    target_.faceRight = !target_.faceRight;
}

@end
